# Program variables (DON'T DELETE!!!)
block_speed = -6 # controls how fast the pipes move across the stage
block_gap = 200 # controls the space between the top and bottom of each pipe
block_interval = 1 # controls how often a new pipe appears
gravity = 8 # controls how fast the sprite falls
flappiness = 5 # controls how much the sprite moves up
# Store and display score
score = 0
score_text = codesters.Text("Score: " + str(score), 100, 200, "yellow")
########################################################################
# ADD CODE BELOW THIS LINE #
########################################################################
stage.set_background("space")
stage.disable_all_walls()
sprite = codesters.Sprite("dinosaur")
sprite.set_size(0.4)
sprite.set_say_color("yellow")
sprite.say("TAP THE SPACE BAR TO GUIDE ME THROUGH THE BLOCKS!", 3)
sprite.go_to(-200, 0)
stage.set_gravity(gravity)
def space_bar():
sprite.jump(flappiness)
stage.event_key("space", space_bar)
def interval():
global score
score += 1
score_text.set_text("Score: " + str(score))
stage.event_interval(interval, block_interval)
def make_blocks():
pass # delete after adding indented code
t = codesters.Teacher()
make_block_calls = t.find_text("make_blocks()")
try:
tval1 = make_block_calls[0][1].lower().replace(' ','')
tval1_indent = t.get_indent_at_line(make_block_calls[0][0])
except:
tval1 = "DNE"
tval1_indent = "DNE"
t1 = TestObjective()
t1.add_success('make_blocks()' in tval1 and ':' not in tval1 and tval1_indent == 4, "Great Job!")
t1.add_failure(tval1 == "DNE", "Oops, did you delete something?")
t1.add_failure(tval1 != "DNE" and ':' in tval1, "Did you place the function call inside the interval event?")
t1.add_failure(tval1 != "DNE" and tval1_indent != 4, "Make sure the function call is indented once in the interval event.")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)